# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=faudio
pkgver=22.07
pkgrel=0
pkgdesc="Accuracy-focused XAudio reimplementation for open platforms"
url="https://fna-xna.github.io/"
arch="all"
license="Zlib"
makedepends="cmake samurai sdl2-dev"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/FNA-XNA/FAudio/archive/$pkgver.tar.gz"
builddir="$srcdir/FAudio-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi

	cmake -G Ninja -B build \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=1 \
		-DBUILD_TESTS=1
	cmake --build build
}

check() {
	cd build
	./faudio_tests
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
20364e9a23c8296aa37cb0cbdbd0d6576069dc9a46da877104e5b924217ef9961dc2668cbfbaed73a5ba54f9b5d90b451e91041282f68ce2a384f478ccfd87a1  faudio-22.07.tar.gz
"
